package com.silence.gmall.product.domain.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.repository.CrudRepository;
import com.silence.gmall.product.assembler.BaseCategory3Factory;
import com.silence.gmall.product.domain.entity.BaseCategory3;
import com.silence.gmall.product.domain.mapper.BaseCategory3Mapper;
import com.silence.gmall.product.domain.repository.BaseCategory3Repository;
import com.silence.gmall.product.dto.BaseCategory3Dto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author silence
 * @Description 针对表【base_category3(三级分类表)】的数据库操作Repository实现
 * @Date 2025-08-17 16:28:16
 */
@Slf4j
@Repository
@RequiredArgsConstructor
public class BaseCategory3RepositoryImpl extends CrudRepository<BaseCategory3Mapper, BaseCategory3>
    implements BaseCategory3Repository {

    /**
     * 三级分类工厂
     */
    private final BaseCategory3Factory baseCategory3Factory;

    /**
     * 根据二级分类ID查询所有三级分类
     *
     * @param category2Id 二级分类ID
     * @return 三级分类列表
     */
    @Override
    public List<BaseCategory3Dto> listBaseCategory3(String category2Id) {
        return baseCategory3Factory.categoryList2CategoryResVoList(list(new LambdaQueryWrapper<BaseCategory3>().eq(BaseCategory3::getCategory2Id, category2Id)));
    }
} 